package com.persistence;

import java.io.InputStream;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import java.io.File;




@Entity(name="MEMBERSHIP")
@Table(name="membership")
@NamedQueries(
		@NamedQuery(name = "selectallMiembros",query = "SELECT M FROM MEMBERSHIP M")
	)
public class Membership implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@TableGenerator(name = "MEMBER_SEQ", table = "tbsequence", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "MEMBER_IDX", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "MEMBER_SEQ")
	@Column(name="ID")
	private Integer id;

	@Column(name="LASTRENEWALDATE")
	@Temporal (value = TemporalType.TIMESTAMP) 
	private Date lastrenewaldate;

	@Column(name="MEMBERSHIP_TYPE")
	private short membershipType;

	@Column(name="MEMBERSINCE")
	@Temporal (value = TemporalType.TIMESTAMP) 
	private Date membersince;

	
	@OneToMany(mappedBy="membership", fetch=FetchType.EAGER)
	private List<Dependent> dependents;

	
	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name="PRIMARYMEMBER",referencedColumnName="ID", insertable=true, updatable=true)
	private Primarymember primarymemberBean;
	
    
    public Membership() {
    }

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getLastrenewaldate() {
		return this.lastrenewaldate;
	}

	public void setLastrenewaldate(Date lastrenewaldate) {
		this.lastrenewaldate = lastrenewaldate;
	}

	public short getMembershipType() {
		return this.membershipType;
	}

	public void setMembershipType(short membershipType) {
		this.membershipType = membershipType;
	}

	public Date getMembersince() {
		return this.membersince;
	}

	public void setMembersince(Date membersince) {
		this.membersince = membersince;
	}

	public List<Dependent> getDependents() {
		return this.dependents;
	}

	public void setDependents(List<Dependent> dependents) {
		this.dependents = dependents;
	}
	
	public Primarymember getPrimarymemberBean() {
		return this.primarymemberBean;
	}

	public void setPrimarymemberBean(Primarymember primarymemberBean) {
		this.primarymemberBean = primarymemberBean;
	}
	
}